package com.example.mybiadushoujiweishi.activity.acivitys;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.ActionBar;
import android.support.v7.widget.Toolbar;
import android.widget.FrameLayout;


import com.example.mybiadushoujiweishi.R;
import com.example.mybiadushoujiweishi.activity.acivitys.base.BaseActivity;
import com.example.mybiadushoujiweishi.activity.acivitys.fragments.Onkeyhelpstart_fragment;

import butterknife.BindView;

public class OnekeyhelpActivity extends BaseActivity {
    @BindView(R.id.control_fragment)
    FrameLayout controlFragment;
    /* @BindView(R.id.one)
     Button one;
     @BindView(R.id.two)
     Button two;*/
    public Fragment fragment = new Fragment();
    @BindView(R.id.onekeytoolbar)
    Toolbar onekeytoolbar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //  setContentView(R.layout.activity_onekeyhelp);
        changeFragment(new Onkeyhelpstart_fragment(), "startfragment");

        setSupportActionBar(onekeytoolbar);
        ActionBar ab=getSupportActionBar();
        ab.setDisplayHomeAsUpEnabled(true);

      /*  FragmentManager fm=getSupportFragmentManager();
        FragmentTransaction transaction=fm.beginTransaction();
        transaction.add(R.id.control_fragment,fragment);
        transaction.commit();*/

    }

    @Override
    public int getContentView() {

        return R.layout.activity_onekeyhelp;
    }

    @Override
    public void initData() {
        //  controlFragment= (FrameLayout) findViewById(R.id.control_fragment);
        //one.setOnClickListener(this);
        //two.setOnClickListener(this);
    }

  /*  @Override
    public void onClick(View v) {

        switch (v.getId()) {

            case R.id.one:

            changeFragment(new Onkeyhelpstart_fragment(),"start");

                break;

            case R.id.two:
                changeFragment(new Onkeyhelphome_fragment(),"home");
                break;
        }

    }*/

    public void changeFragment(Fragment targeFragment, String tag) {

        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        if (!targeFragment.isAdded()) {

            if (fragment != null) {
                transaction.hide(fragment);
            }
            transaction.add(R.id.control_fragment, targeFragment).commit();
        } else {
            transaction.hide(fragment)
                    .show(targeFragment)
                    .commit();

        }
        fragment = targeFragment;

    }



}
